import java.io.*;
import java.util.*;

public class FileToHashtable  {

    private Hashtable hashTable = new Hashtable();
    private Vector fVector = new Vector();
    private File name = null;

    public void setFileName( String file_name )
    {
	name = new File (file_name);
    }

    public void setFileName( String dir_name, String file_name )
    {
	name = new File (dir_name, file_name);
    }

    public void setFileName( File fname )
    {
	name = fname;
    }

    public Hashtable getHashTable () {
	return hashTable;
    }

    public Vector getVector () {
	return fVector;
    }

    public void loadFile () {

        if ( !name.exists() ) {
	    System.out.println("File:"+name.getName()+" not found!");
	    return;
	}

	if ( name.isFile() ) {
	   try {
               FileReader r =  new FileReader ( name );
	       BufferedReader br = new BufferedReader (r);

               String text;
	       String key;
	       String valume;

               while( ( text = br.readLine() ) != null ) {
		   StringTokenizer tokens = new StringTokenizer(text);
		   while (tokens.hasMoreTokens()) {
		       key = tokens.nextToken();
		       valume = tokens.nextToken();
		       if (key != null && valume != null) {
			   System.out.println("hashtable:"+key+"\t"+valume);
			   hashTable.put(key, valume);
			   fVector.addElement(key);
			   fVector.addElement(valume);
		       }
		   }
	       }
	       System.out.println(hashTable);
	       Enumeration enum = fVector.elements();
	       String temp;
	       while ( enum.hasMoreElements() ) {
		   temp = (String)enum.nextElement();
		   System.out.println("22222222: "+temp);
	       }
	       br.close();
	       r.close();
	   }
	   catch( IOException e ) {

	   }
       }
    }
}





